/**
 * 
 */
package wong.board.client.util;

import com.google.gwt.dom.client.Element;

/**
 * @author wong
 * 
 */
public class JSTool {

	protected JSTool() {
	}

	public static native String getNavigatorOsCpu() /*-{
		return navigator.oscpu;
	}-*/;

	public static native ClientRect getBoundingClientRect(Element element) /*-{
		return element.getBoundingClientRect();
	}-*/;

	//

	public static void openWindow(String url, String target, boolean replace, boolean requestFocus) {
		openWindow(url, target, null, replace, requestFocus);
	}

	public static void openWindow(String url, String target, String features, boolean replace,
			boolean requestFocus) {
		openWindowNative(url, target, features, replace, requestFocus);
	}

	private static native void openWindowNative(String url, String target, String features, boolean replace,
			boolean requestFocus) /*-{
		if (!$wnd._jstool_windows) {
			$wnd._jstool_windows = new Object();
		}

		$wnd._jstool_windows[target] = $wnd
				.open(url, target, features, replace);

		if (requestFocus && $wnd._jstool_windows[target]
				&& $wnd._jstool_windows[target].focus) {
			$wnd._jstool_windows[target].focus();
		}
	}-*/;

}
